<template>
	<view>
		<!-- 车辆维修 -->
		<view>车辆维修</view>

		<u-button @click="toMap(type[0])">导航</u-button>
		<u-button @click="toSearch(type[0])">附近门店</u-button>
		<u-button @click="toShopDetail(type[0],1)">门店详情</u-button>

		<u-button @click="reserve(1)">立即预约</u-button>
		<u-button @click="resSuccess(1)">预约成功</u-button>

		<u-button @click="resDetail(114514)">预约详情</u-button>

		<!-- 车辆保养 -->
		<view>车辆保养</view>

		<u-button @click="toMap(type[1])">导航</u-button>
		<u-button @click="toSearch(type[1])">附近门店</u-button>
		<u-button @click="toShopDetail(type[1],1)">门店详情</u-button>

		<u-button @click="confirmOrder(1)">确认订单</u-button>



        <u-datetime-picker
                :show="show"
                v-model="date"
                mode="datetime"
				@close="close"
				@cancel="close"
				@confirm="confirm"
				:closeOnClickOverlay="true"
        ></u-datetime-picker>
		<u-button @click="show = true">打开</u-button>
		<view>日期：{{new Date(date)}}</view>

		<image style="width: 300rpx;height: 120rpx;background-color: antiquewhite;" :src="src" @click="getCode"></image>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
				date:Number(new Date()),
				form:{
					date:null,
					subscribeTime:null
				},				
				type: ['车辆维修', '车辆保养'],
				src: '',
			}
		},
		onLoad() {
			
		},
		methods: {
			close(){
				this.show = false
			},
			confirm(){
				new Date().getMinutes()
				let date = new Date(this.date)
				this.form.subscribeTime = date.getFullYear()+'-'
				+(date.getMonth()+1)+'-'
				+date.getDate()+' '
				+date.getHours()+':'+
				+date.getMinutes()+':00'
				
				this.show = false
				console.log(this.form)
			},
			getCode() {
				let that = this
				uni.request({
					url: '/api/code',
					success(res) {
						// console.log(res.data)
						that.src = "data:image/gif;base64," + res.data.img
					}
				})
			},
			toMap(type) {
				uni.navigateTo({
					url: `/pages/yunRang/carMaintainReservation/cmr_search_map/cmr_search_map?type=${type}`
				})
			},
			toSearch(type) {
				uni.navigateTo({
					url: `/pages/yunRang/carMaintainReservation/cmr_search/cmr_search?type=${type}`
				})
			},
			toShopDetail(type, id) {
				uni.navigateTo({
					url: `/pages/yunRang/carMaintainReservation/cmr_clean/cmr_clean?type=${type}&id=${id}`
				})
			},
			reserve(id) {
				uni.navigateTo({
					url: `/pages/yunRang/carMaintainReservation/cmr_add/cmr_add?id=${id}`
				})
			},
			resSuccess(id) {
				uni.navigateTo({
					url: `/pages/yunRang/carMaintainReservation/cmr_success/cmr_success?id=${id}`
				})
			},
			resDetail(id) {
				uni.navigateTo({
					url: `/pages/yunRang/carMaintainReservation/cmr_detail/cmr_detail?id=${id}`
				})
			},
			confirmOrder(id) {
				uni.navigateTo({
					url: `/pages/yunRang/carMaintainReservation/order_confirm/order_confirm?id=${id}`
				})
			}


		}
	}
</script>

<style>

</style>